package edu.uow.devdocs

class CurrentUserService {
	static scope = "session"
	long personId
	def springSecurityService

    def Person getCurrentUser() {
		return Person.get(getCurrentUserId())
    }
	
	def Integer getCurrentUserId() {
		if (!personId) {
			println springSecurityService.principal.username
			personId = Person.findByUsername(springSecurityService.principal.username).id
		}
		return personId
	}
	
	
}
